package v1

import (
	"encoding/json"
	"geek-cloud-native/chapter04-0925/global"
	"github.com/julienschmidt/httprouter"
	"net/http"
)

type Healthz struct {
}

func NewHealthz() *Healthz {
	return &Healthz{}
}

func (h *Healthz) HealthCheck(writer http.ResponseWriter, request *http.Request, params httprouter.Params) {
	response := map[string]interface{}{
		"status": http.StatusOK,
		"msg":    "监控检测页面",
	}
	resB, _ := json.Marshal(response)
	_, err := writer.Write(resB)
	if err != nil {
		global.Logger.Error("health check failed")
	}
	global.Logger.Info("health check success. ")
}
